package com.pwc.conversionTool.IO;

import java.io.File;

import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * basic function for operation file in project
 */
public class FileOperation {
	public FileOperation() {
		super();
	}

	// copy file
	public static void copyFileToDirectory(File file, File path)
			throws IOException {
		FileUtils.copyFileToDirectory(file, path);
	}

	// delete file
	public static void deleteFile(File file) {
		FileUtils.deleteQuietly(file);
	}

	// cut === copy and delete
	public static void cutFileToDirectory(File file, File path)
			throws IOException {

		if (path.isDirectory()) {
			String targetPath = path.getPath() + File.separator
					+ file.getName();
			file.renameTo(new File(targetPath));
		} else {
			file.renameTo(path);
		}

	}

}
